<div style="text-align: center; display: none;">
  <div class="timeline_show_more"><a style="color: black; text-decoration: none; cursor: pointer; margin-top: 10px;"><i class="icon icon-chevron-down"></i>&nbsp;<b>more</b>&nbsp;<i class="icon icon-chevron-down"></i></a></div>
  <div class="timeline_show_less"><a style="color: black; text-decoration: none; cursor: pointer; margin-top: -5px;"><i class="icon icon-chevron-up"></i>&nbsp;<b>less</b>&nbsp;<i class="icon icon-chevron-up"></i></a></div>
</div>
<div style="text-align: center; margin-left: 25px;">
  <div class="badge badge-inverse"><?php echo date('d M Y', strtotime($timelineDate)); ?></div>
</div>
<?php if (!empty($activity_data)) { ?>
  <ul class="timeline messages">
	<?php $count = 0; ?>
	<?php foreach ($activity_data as $activity) { ?>
	  <li <?php if ($count % 2 != 0) { ?>class="timeline-inverted" <?php } ?>>
		<?php
		$post_key = null;
		$text = null;
		$msg = null;
		$icon = null;
		$show_likes = false;
		$show_comments = false;
		$show_votes = false;
		$show_photos = false;
		switch ($activity['activity_type']) {
		  case 1:
			$post_key = 'tweet';
			$text = 'added a new <b>tweet</b>';
			$msg = $activity['activity_message'];
			$icon = 'icon-pencil';
			$show_likes = true;
			$show_comments = false;
			break;
		  case 2:
			$post_key = 'reply';
			$text = 'replied to a <b>tweet</b>';
			$msg = $activity['activity_message'];
			$icon = 'icon-comment';
			$show_likes = true;
			$show_comments = false;
			break;
		  case 3:
			$post_key = 'event';
			$text = 'added a new <b>event</b>';
			$msg = $activity['activity_message'];
			$icon = 'icon-calendar';
			$show_likes = false;
			$show_comments = false;
			break;
		  case 4:
			$post_key = 'album';
			$text = 'added a new <b>album</b>';
			$msg = $activity['activity_message'];
			$icon = 'icon-picture';
			$show_likes = true;
			$show_comments = false;
			break;
		  case 5:
			$post_key = $activity['activity_item_type'];
			$text = 'likes a <b>' . $activity['activity_item_type'] . '</b>';
			$msg = $activity['activity_message'];
			$icon = 'icon-thumbs-up';
			$show_likes = true;
			if ($activity['activity_item_type'] == 'photo' || $activity['activity_item_type'] == 'video' || $activity['activity_item_type'] == 'poll') {
			  $show_comments = true;
			} else {
			  $show_comments = false;
			}
			break;
		  case 6:
			$post_key = 'wall_post';
			$text = 'posted on someones <b>wall</b>';
			$msg = $activity['activity_message'];
			$icon = 'icon-comment';
			$show_likes = true;
			$show_comments = false;
			break;
		  case 7:
			$post_key = 'poll';
			$text = 'added a new <b>poll</b>';
			$msg = $activity['activity_message'];
			$icon = 'icon-tasks';
			$show_likes = true;
			$show_comments = true;
			break;
		  case 8:
			$post_key = 'poll';
			$text = 'voted on a <b>poll</b>';
			$msg = $activity['activity_message'];
			$icon = 'icon-tasks';
			$show_likes = true;
			$show_comments = true;
			break;
		  case 9:
			$post_key = $activity['activity_item_type'];
			$text = 'commented on a <b>' . $activity['activity_item_type'] . '</b>';
			$msg = $activity['activity_message'];
			$icon = 'icon-comment';
			$show_likes = true;
			$show_comments = true;
			break;
		}

		$get_like_type_data = get_like_type_data($post_key, $activity['activity_id']);

		switch ($activity['activity_type']) {
		  case 1:
			$msg = $activity['activity_message'] . " - " . $get_like_type_data['tweet_message'];
			break;
		  case 5:
			if ($activity['activity_item_type'] == 'tweet') {
			  $msg = $activity['activity_message'] . " - " . $get_like_type_data['tweet_message'];
			}
			break;
		  case 6:
			$text = 'posted on ' . $get_like_type_data['user_name'] . '`s <b>wall</b>';
			break;
		}

		$msg = strip_tags(preg_replace('/(<br>)+$/', '', $msg), '<img>');
		?>
		<div class="timeline-panel">
		  <div class="timeline-body">
			<a href="<?php echo base_url('profile/' . $activity['user_name']); ?>"><img title="<?php echo $activity['user_name']; ?>" src="<?php echo base_url('assets/photos/' . $activity['user_image']); ?>" class="img-rounded pull-left" style="max-height: 60px; max-width: 60px;"/></a>
			<div class="message-body">
			  <div class="pull-right" style="margin-top: 3px;"><i class="<?php echo $icon; ?>"></i></div>
			  <div style="color: black;">
				<?php if (is_online($activity['user_id'])) { ?>
	  			<img src="<?php echo site_url('assets/img/online_button_tiny.png'); ?>" title="Online"/>
				<?php } else { ?>
	  			<img src="<?php echo site_url('assets/img/offline_button_tiny.png'); ?>" title="Offline"/>
				<?php } ?>
				<a style="text-decoration: none; color: #333333;" href="<?php echo base_url('profile/' . $activity['user_name']); ?>"><?php echo '@' . $activity['user_name']; ?></a>
				<small style="color: #8e8e8e;"><?php echo $text; ?></small>
				<h6 style="color: #333333; margin-top: 0px;"><?php echo date('d M Y h:i a', strtotime($activity['activity_date'])); ?></h6>
			  </div>
			  <div class="timeline_item_content_<?php echo $offset; ?>">
				<a style="text-decoration: none;" href="<?php echo site_url('redirect?post_id=' . make_post_id($post_key, $activity['activity_id'])); ?>">
				  <?php if ($activity['activity_type'] == 5 && ($post_key == 'photo' || $post_key == 'video')) { ?>
	  			  <p>
	  				<img style="width: 100%;" src="<?php echo $activity['activity_image_url'] ?>"/>
	  			  </p>
				  <?php } elseif (($activity['activity_type'] == 4) || ($activity['activity_type'] == 5 && $post_key == 'album')) { ?>
					<?php $album_photos = get_album_photos($activity['activity_id'], 6); ?>
					<?php $show_photos = true; ?>
	  			  <p style="word-break: normal; color: #333333;"><?php echo nl2br(parse_smileys($msg, base_url('assets/smileys'))) . '...'; ?></p>
					<?php if (!empty($album_photos['photos'])) { ?>
					  <ul class="thumbnails">
						<?php foreach ($album_photos['photos'] as $album_photo) { ?>
		  				<li>
		  				  <img class="thumbnail" style="max-height: 88px;" src="<?php echo base_url('assets/albums/' . $activity['activity_id'] . '/' . substr($album_photo['photo_file'], 0, 32) . '_thumb.jpg'); ?>">
		  				</li>
						<?php } ?>
					  </ul>
					<?php } else { ?>
					  <div class="alert alert-info">No photos</div>
					<?php } ?>
				  <?php } elseif (($activity['activity_type'] == 7) || ($activity['activity_type'] == 8) || ($activity['activity_type'] == 5 && $post_key == 'poll')) { ?>
					<?php $poll_options = get_poll_options($activity['activity_id']); ?>
					<?php $show_votes = true; ?>
	  			  <p style="word-break: normal; color: #333333;"><?php echo nl2br(parse_smileys($msg, base_url('assets/smileys'))) . '...'; ?></p>
					<?php if (!empty($poll_options['options'])) { ?>
					  <div class="widget">
						<table style="width:100%;">
						  <?php foreach ($poll_options['options'] as $poll_option) { ?>
							<?php $poll_option_reply_count = get_poll_reply_count($poll_option['poll_option_id']); ?>
							<?php $poll_option_percent = @(((int) $poll_option_reply_count / (int) $poll_options['votes']) * 100); ?>
		  				  <tr id="poll_option_box_2_<?php echo $poll_option['poll_option_id']; ?>">
		  					<td width="30" title="<?php echo $poll_option['poll_option_message']; ?>"><?php echo mb_substr($poll_option['poll_option_message'], 0, 25) . '...'; ?></td>
		  					<td width="30" id="option_bar_count_<?php echo $poll_option['poll_option_id']; ?>"><?php echo $poll_option_reply_count; ?> votes</td>
		  					<td width="40" id="option_bar_title_<?php echo $poll_option['poll_option_id']; ?>" title="<?php echo ceil($poll_option_percent) . '%'; ?>">
		  					  <div class="progress">
		  						<div class="bar" id="option_bar_width_<?php echo $poll_option['poll_option_id']; ?>" style="<?php echo 'width: ' . $poll_option_percent . '%'; ?>"></div>
		  					  </div>
		  					</td>
		  				  </tr>
						  <?php } ?>
						  <tr id="new_poll_option_2" style="display: none;"></tr>
						</table>
					  </div>
					<?php } ?>
				  <?php } elseif ($activity['activity_type'] == 9 && ($post_key == 'photo' || $post_key == 'video')) { ?>
	  			  <img style="width: 100%;" src="<?php echo $activity['activity_image_url'] ?>"/>
	  			  <p style="word-break: normal; color: #333333;"><?php echo nl2br(parse_smileys($msg, base_url('assets/smileys'))) . '...'; ?></p>
				  <?php } else { ?>
	  			  <p style="word-break: normal; color: #333333;"><?php echo nl2br(parse_smileys($msg, base_url('assets/smileys'))) . '...'; ?></p>
				  <?php } ?>
				</a>
			  </div>
			  <div style="color: #000; margin-top: 15px;">
				<?php if (!empty($get_like_type_data['user_name'])) { ?>
	  			<span title="<?php echo $get_like_type_data['user_display_name']; ?>" style="cursor: pointer; color: #000"><i class="icon-user"></i>&nbsp;@<?php echo $get_like_type_data['user_name']; ?></span>
				<?php } ?>
				<?php if (!empty($get_like_type_data['user_name']) && $show_likes) { ?>
	  			&nbsp;|&nbsp;
				<?php } ?>
				<?php if ($show_likes) { ?>
				  <?php $get_user_like_status = get_user_like_status($post_key, $activity['activity_id']); ?>
				  <?php $like_button_id = 'like_button_' . $post_key . '_' . $activity['activity_id']; ?>
				  <?php $like_text_id = 'like_count_' . $post_key . '_' . $activity['activity_id']; ?>
				  <?php if ($get_user_like_status['status'] == 'yes') { ?>
					<a title="Unlike" style="text-decoration: none; cursor: pointer; color: #000" id="<?php echo $like_button_id; ?>" onclick="return do_like_action('<?php echo $post_key; ?>', '<?php echo $activity['activity_id']; ?>', '0');"><i class="icon-large icon-thumbs-down"></i></a>
				  <?php } else { ?>
					<a title="Like" style="text-decoration: none; cursor: pointer; color: #000" id="<?php echo $like_button_id; ?>" onclick="return do_like_action('<?php echo $post_key; ?>', '<?php echo $activity['activity_id']; ?>', '1');"><i class="icon-large icon-thumbs-up"></i></a>
				  <?php } ?>
	  			<a class="update_like_count" title="Show users who like this" onclick="return show_liked_users('<?php echo $post_key; ?>', '<?php echo $activity['activity_id']; ?>');" style="text-decoration: none; cursor: pointer; color: #000" id="<?php echo $like_text_id; ?>"><?php echo $get_user_like_status['total_count']; ?> Likes</a>
				<?php } ?>
				<?php if ($show_likes && $show_comments) { ?>
	  			&nbsp;|&nbsp;
				<?php } ?>
				<?php if ($show_comments) { ?>
				  <?php $get_comments = get_comments($post_key, $activity['activity_id']); ?>
	  			<span title="<?php echo (int) count($get_comments); ?> comments" style="cursor: pointer; color: #000"><i class="icon-comment"></i>&nbsp;<?php echo (int) count($get_comments); ?> comments</span>
				<?php } ?>
				<?php if ($show_photos) { ?>
	  			&nbsp;|&nbsp;
	  			<span title="<?php echo (int) $album_photos['total']; ?> photos" style="cursor: pointer; color: #000"><i class="icon-picture"></i>&nbsp;<?php echo (int) $album_photos['total']; ?> photos</span>
				<?php } ?>
				<?php if ($show_votes) { ?>
	  			&nbsp;|&nbsp;
	  			<span title="<?php echo (int) $poll_options['votes']; ?> votes" style="cursor: pointer; color: #000"><i class="icon-random"></i>&nbsp;<?php echo (int) $poll_options['votes']; ?> votes</span>
				<?php } ?>
			  </div>
			</div>
		  </div>
		</div>
	  </li>
	  <?php $count++; ?>
	<?php } ?>
  </ul>
<?php } else { ?>
  <div style="text-align: center; margin-left: 25px; margin-bottom: 5px; margin-bottom: 10px;">
	<?php $tm_day = strtolower(date('D', strtotime($timelineDate))); ?>
	<?php if ($tm_day == 'sun' || $tm_day == 'sat') { ?>
	  <div style="font-size: smaller;">Saturday / Sunday Holiday</div>
	<?php } else { ?>
	  <div style="font-size: smaller;">Sleepy innovators. No activities on this day.</div>
	<?php } ?>
    <div style="font-size: x-small; margin-top: -10px;">Scorll down for more !</div>
  </div>
<?php } ?>

<script type="text/javascript">
  $(document).ready(function() {
	$('.timeline_item_content_<?php echo $offset; ?>').readmore({
	  maxHeight: 350,
	  moreLink: $('.timeline_show_more').html(),
	  lessLink: $('.timeline_show_less').html()
	});
  });
<?php if (!empty($last_active_day)) { ?>
    $('#timeline_offset').val('<?php echo $last_active_day; ?>');
<?php } ?>
</script>
